from django.db import models
from util.const import *


# Create your models here.
class ConditionOrder(models.Model):

    order_type = models.CharField('订单类型', max_length=30)
    side = models.CharField('买卖方向', max_length=30)
    # max_digits must larger than decimal_places
    condition_price = models.DecimalField('触发价', max_digits=19, decimal_places=8)
    order_status = models.CharField('订单状态', max_length=30, default=ORDER_STATUS_CREATE, blank=True)
    order_time = models.DateTimeField('创建时间', auto_now_add=True)
    # 最新价，买一价，卖一价的索引
    price_type = models.IntegerField('价格类型')
    symbol = models.CharField('币对', max_length=30)
    qty = models.DecimalField('数量', max_digits=19, decimal_places=8)
    # 索引从0开始，依次为 >,>=,<,<=
    compare_type = models.IntegerField("触发条件")
    price = models.DecimalField('下单价格', max_digits=19, decimal_places=8)
    fail_reason = models.CharField('失败原因', default="", max_length=300, blank=True)
    user_name = models.CharField('用户', max_length=100)
    condition_order_id = models.AutoField(primary_key=True)
    cookies = models.CharField('用户cookie', default="", max_length=300)
